package com.woniuxy.microshoppingcartserver.listener;

import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
public class RabbitMQListener {
    /**
     * @RabbitHandler 处理Rabbit数据
     * @RabbitListener(queues = {"emailQueue"}) 监听某一个队列
     */
    @RabbitHandler
    @RabbitListener(queues = {"emailQueue"})
    public void listener01(Map<String,Object> data){
        data.forEach((k,v)->{
            System.out.println(k + "-----" + v);
        });
    }
    @RabbitHandler
    @RabbitListener(queues = {"topic.email"})
    public void listener02(Map<String,Object> data){
        data.forEach((k,v)->{
            System.out.println(k + "-----" + v);
        });
    }
    @RabbitHandler
    @RabbitListener(queues = {"fanout.A"})
    public void listener03(Map<String,Object> data){
        data.forEach((k,v)->{
            System.out.println(k + "-----" + v);
        });
    }
}